package net.zjitc.controller;

import net.zjitc.pojo.Category;
import net.zjitc.pojo.CategorySecond;
import net.zjitc.pojo.Product;
import net.zjitc.service.AdminProductService;
import net.zjitc.service.CategorySecondService;
import net.zjitc.service.CategoryService;
import net.zjitc.service.impl.AdminProductServiceImpl;
import net.zjitc.service.impl.CategorySecondSerImpl;
import net.zjitc.service.impl.CategoryServiceImpl;
import net.zjitc.utils.dispacher.URLMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * Created by Administrator on 2017/12/4.
 */
public class IndexController {
    //商城首页
    @URLMapping(url = "/index")
    public String index(HttpServletRequest request, HttpServletResponse response){
        //菜单栏显示一级菜单
        CategoryService service=new CategoryServiceImpl();
        List<Category> clist=service.findAll();
        request.setAttribute("clist",clist);
        //热门商品
        AdminProductService productService=new AdminProductServiceImpl();
        List<Product> phlist=productService.findHot();
        request.setAttribute("phlist",phlist);
        //最新商品
        List<Product> pnewlist=productService.findNew();
        request.setAttribute("pnewlist",pnewlist);
        return "/WEB-INF/user/index.jsp";
    }
}
